/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package consumo.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Carlos Taschetto
 */
@Entity
@Table(name = "tarifa", catalog = "consumodb", schema = "")
@NamedQueries({
    @NamedQuery(name = "Tarifa.findAll", query = "SELECT t FROM Tarifa t"),
    @NamedQuery(name = "Tarifa.findById", query = "SELECT t FROM Tarifa t WHERE t.id = :id")})
public class Tarifa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarifa")
    private List<Verde> verdeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarifa")
    private List<Azul> azulList;
    @JoinColumn(name = "tipo_tarifa", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private TipoTarifa tipoTarifa;
    @JoinColumn(name = "conce", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false, fetch= FetchType.EAGER)
    private Concessionaria conce;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarifa")
    private List<Contrato> contratoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarifa")
    private List<BaixaTensao> baixaTensaoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarifa")
    private List<Convencional> convencionalList;

    public Tarifa() {
    }

    public Tarifa(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public List<Verde> getVerdeList() {
        return verdeList;
    }

    public void setVerdeList(List<Verde> verdeList) {
        this.verdeList = verdeList;
    }

    public List<Azul> getAzulList() {
        return azulList;
    }

    public void setAzulList(List<Azul> azulList) {
        this.azulList = azulList;
    }

    public TipoTarifa getTipoTarifa() {
        return tipoTarifa;
    }

    public void setTipoTarifa(TipoTarifa tipoTarifa) {
        this.tipoTarifa = tipoTarifa;
    }

    public Concessionaria getConce() {
        return conce;
    }

    public void setConce(Concessionaria conce) {
        this.conce = conce;
    }

    public List<Contrato> getContratoList() {
        return contratoList;
    }

    public void setContratoList(List<Contrato> contratoList) {
        this.contratoList = contratoList;
    }

    public List<BaixaTensao> getBaixaTensaoList() {
        return baixaTensaoList;
    }

    public void setBaixaTensaoList(List<BaixaTensao> baixaTensaoList) {
        this.baixaTensaoList = baixaTensaoList;
    }

    public List<Convencional> getConvencionalList() {
        return convencionalList;
    }

    public void setConvencionalList(List<Convencional> convencionalList) {
        this.convencionalList = convencionalList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tarifa)) {
            return false;
        }
        Tarifa other = (Tarifa) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "consumo.persistence.Tarifa[id=" + id + "]";
    }

}
